/-boot
BootController.ts
BootLayout.ts
StorageLoader.ts
boot.ts
/-docs
/-docs/CodeMirrorServices
/-docs/types
/-editor
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
FileEntry.ts
FileList.ts
FolderEntry.ts
functions.ts
/-files-old ...
FileEntry.ts
FolderEntry.ts
impl.ts
/-imports
/-layout
MainLayout.ts
file.html
folder.html
page.html
teapo.css
/-shell
EditorShell.ts
/-storage
/-tests
/-typings
Dom.ts
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
tmp.ts
try.html
try.js
x
    treeClick(data_unused, event: MouseEvent) {
1
module teapo {
2
​
3
  /**
4
   * File list/tree ViewModel.
5
   */
6
  export class FileList {
7
​
8
    /**
9
     * Top level folders.
10
     */
11
    folders = ko.observableArray<FolderEntry>();
12
​
13
    /**
14
     * Files directly in the root folder.
15
     */
16
    files = ko.observableArray<FileEntry>();
17
​
18
    /**
19
     * Currently selected file. Should not be modified externally.
20
     */
21
    selectedFile = ko.observable<FileEntry>(null);
22
​
23
    private _filesByFullPath: { [fullPath: string]: FileEntry; } = {};
24
​
25
    constructor(private _storage: DocumentStorage) {
26
      var fileNames = this._storage.documentNames();
27
      for (var i = 0; i < fileNames.length; i++) {
28
​
29
        if (fileNames[i].charAt(0) !== '/')
30
          continue; // ignore hidden files
31
​
32
        this._addFileEntry(fileNames[i]);
33
      }
34
    }
35
​
36
    /**
37
     * Find a file from its path.
38
     */
39
    getFileEntry(fullPath: string): FileEntry {
40
      if (fullPath.charAt(0) !== '/')
41
        return null; // ignore hidden files
42
​
43
      return this._filesByFullPath[fullPath];
44
    }
45
​
46
    /**
47
     * Create a file entry (throwing an exception if one already exists).
48
     * Note that only the list/tree structures are created,
49
     * not touching editor nor persistence part of cocerns.
50
     */
51
    createFileEntry(fullPath: string): FileEntry {
52
      return this._addFileEntry(fullPath);
53
    }
0:0